package summer.codegenerator.service.base;

import java.util.List;

import org.hibernate.criterion.Order;

import summer.codegenerator.persistence.hibernate.base.tool.Pagination;
import summer.codegenerator.persistence.hibernate.base.tool.Sort;
import summer.codegenerator.persistence.hibernate.base.tool.WhereClause;

import com.alibaba.fastjson.JSONObject;

/**
 * @author Administrator
 *
 */
public interface BaseService<T> {

	T copyById(Long id);
	
	void saveClear(T entity);
	
	void updateClear(T entity);

	T save(T entity) throws Exception;

	T update(T entity) throws Exception;

	void delete(T entity);

	void delete(final Long entityId);

	void delete(final List<Long> entityIds);

	List<T> list(WhereClause whereClause);

	List<T> list(WhereClause whereClause, Sort sort);

	List<T> list(WhereClause whereClause, Sort sort, Pagination pagination);

	Long countTotal(WhereClause whereClause);
	
	/**
	 * 通用请求
	 * @param condition     对其进行递归解析
	 * @param orders        排序
	 * @param pagination    分页
	 * @return 这里返回的数据用于传输的全新对象
	 */
	List<T> listByCriteria(JSONObject condition, List<Order> orders, Pagination pagination);

	Long countTotalByCriteria(JSONObject condition);
	
	void removeAll(List<T> list);
	
	void remove(T entity);
}
